package com.example.computer_exam_training_sys.mapper;

import com.example.computer_exam_training_sys.entity.KnowledgePointInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface KnowledgePointMapper {

    @Select("SELECT * FROM knowledge_points WHERE point_id = #{pointId};")
    public KnowledgePointInfo findById(int pointId);

    @Select("SELECT * FROM knowledge_points ")
    public List<KnowledgePointInfo> findAll();

    @Select("SELECT * FROM knowledge_points WHERE course_id = #{courseId};")
    public List<KnowledgePointInfo> findByCourse(int courseId);

    @Select("SELECT point_id FROM knowledge_points WHERE course_id = #{courseId} LIMIT 1")
    Integer getFirstPointIdByCourseId(@Param("courseId") Integer courseId);


    @Select("SELECT COUNT(*) FROM knowledge_points WHERE course_id = #{courseId}")
    int countByCourseId(@Param("courseId") Integer courseId);

}
